﻿@model ECatalog.Models.Models.ModelView
@{
    Layout = null;
}

<div class="modal fade" id="colorModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title">Цвета</h4>
            </div>
            <div class="modal-body">
                @using (Ajax.BeginForm("Add", "Color", new AjaxOptions { UpdateTargetId = "Colors", HttpMethod = "POST", InsertionMode = InsertionMode.InsertAfter }))
                {
                    @Html.HiddenFor(m => m.ModelId)
                    @Html.HiddenFor(m => m.OrganizationId)
                    <div class="row col-lg-12">
                        <div class="col-lg-1">
                            @Html.Hidden("RgbNumber")
                            <div class="preview" id="rgb-number"></div>
                            <div class="colorpicker" style="display: none; z-index: 999;">
                                <canvas id="picker" width="300" height="300"></canvas>
                                <div class="controls">
                                    <div>
                                        <label>RGB</label><input id="rgbVal" type="text" />
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="col-lg-5">
                            @Html.TextBox("Name", "", new { @class = "form-control" })
                        </div>
                        <div class="col-lg-2">
                            <input type="submit" class="btn btn-primary" value="Добавить" />
                        </div>
                    </div>
                    <div class="row col-lg-12" id="Colors"></div>
                }
                <div class="row col-lg-12">
                    @if (Model != null && Model.Colors.Any())
                    {
                        foreach (var item in Model.Colors)
                        {
                        <div class="row color-item">
                            <div class='col-lg-1'>
                                <div class="preview-read" style="background-color: rgb(@item.RgbNumber); "></div>
                            </div>
                            <div class='col-lg-5'><span>@item.Name</span></div>
                            <div class='col-lg-1 remove-color' id='@item.ColorId'><a href='#'>удалить</a></div>
                        </div>
                        }
                    }
                </div>

            </div>
            <div class="modal-footer">
                 @if (@Model != null)
                {
                    using (Html.BeginForm("EditModel", "Model", new { modelId = @Model.ModelId }))
                    {
                    <button type="submit" class="btn btn-default">Закрыть</button>
                    }
                }
            </div>
        </div>
    </div>
</div>
